package com.example.finance_manager.pages;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;

import com.example.finance_manager.R;
import com.example.finance_manager.pages.manage.DataManageActivity;
import com.example.finance_manager.pages.newly_increased.*;
import com.example.finance_manager.pages.my.*;

public class HomeActivity extends AppCompatActivity {

    private ImageView ivAddIncome;
    private ImageView ivAddExpense;
    private ImageView ivMyIncome;
    private ImageView ivMyExpend;
    private ImageView ivManageData;
    private ImageView ivSysSetting;
    private ImageView ivFlag;
    private ImageView ivExit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        initView();
        initListener();
    }

    private void initView() {
        ivAddIncome = (ImageView) findViewById(R.id.iv_home_add_income);
        ivAddExpense = (ImageView) findViewById(R.id.iv_home_add_expense);
        ivMyIncome = (ImageView) findViewById(R.id.iv_home_my_income);
        ivMyExpend = (ImageView) findViewById(R.id.iv_home_my_expend);
        ivManageData = (ImageView) findViewById(R.id.iv_home_manage_data);
        ivSysSetting = (ImageView) findViewById(R.id.iv_home_system_setting);
        ivFlag = (ImageView) findViewById(R.id.iv_home_flag);
        ivExit = (ImageView) findViewById(R.id.iv_home_exit);
    }

    private void initListener() {
        ivAddIncome.setOnClickListener(view -> {
            to(AddIncomeActivity.class);
        });
        ivAddExpense.setOnClickListener(view -> {
            to(AddExpenseActivity.class);
        });
        ivMyIncome.setOnClickListener(view -> {
            to(MyIncomeActivity.class);
        });
        ivMyExpend.setOnClickListener(view -> {
            to(MyExpendActivity.class);
        });
        ivManageData.setOnClickListener(view -> {
            to(DataManageActivity.class);
        });
        ivFlag.setOnClickListener(view -> {
            to(FlagActivity.class);
        });
        ivSysSetting.setOnClickListener(view -> {
            to(SystemSettingActivity.class);
        });
        ivExit.setOnClickListener(view -> {
            System.exit(0);
        });
    }

    private void to(Class<?> c) {
        Intent intent = new Intent(HomeActivity.this, c);
        startActivity(intent);
    }
}